layui.use(['layer', 'form', 'admin', 'laydate', 'ax', 'formSelects','upload'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var upload = layui.upload;

    //多图片上传
    upload.render({
    		elem: '#test2' //绑定元素
            ,url: 'https://www.idjglobalapp.com/app-servce/v1/api/upload' //上传接口
            ,method: 'POST'
            ,done: function(res){
                //上传完毕
                if(res.code == 1){
                    $('#demo2').append('<img style="width: 150px;height: 100px;padding-left: 5px;" src="'+ res.data +'" class="layui-upload-img">');
                }
             }
      });

    // 添加表单验证方法
    form.verify({
        repsw: function (value) {
            if (value !== $('#userForm input[name=password]').val()) {
                return '两次密码输入不一致';
            }
        }
    });

    // 表单提交事件
    form.on('submit(btnSubmit)', function (data) {
    	var rejectionImg ='';
    	$("#demo2 img").each(function(){
    		var img_url = $(this).attr("src");
    		if(rejectionImg == ''){
    			rejectionImg += img_url;
    		}else{
    			rejectionImg +=","+img_url;
    		}
    	});
        var artistAuthenticatioId = $("#artistAuthenticatioId").val();
        var reasonType = $("#status").find("option:selected").val();
        var writeReason = $("#writeReason").val();
        var pushId = $("#pushId").val();
        var sex = $('input:radio:checked').val();
        var data = {
        		artistAuthenticatioId: artistAuthenticatioId,
            auditRejectionImg: JSON.stringify(rejectionImg),
            reasonType: reasonType,
            writeReason: writeReason,
            pushId: pushId,
            isAudit:2
        }
        // 异步请求
        $.ajax({
            url: Feng.ctxPath + "/modular/iartist_authentication/update",
            data: JSON.stringify(data),
            type: "post",
            contentType: "application/json;charset=UTF-8",
            async: false,//关闭异步请求
            dataType: "json",
            success: function (data) {
                if (data.code == 200) {
                    Feng.success("操作成功！");
                    //传给上个页面，刷新table用
                    // window.parent.location.reload();
                    admin.putTempData('formOk', true);
                    //关掉对话框
                    admin.closeThisDialog();
                } else {
                    Feng.success("操作失败！" + data.message);
                }
            }
            ,
            error: function (data) {
                Feng.error("添加失败！" + data.message)
            }
        });
    });
    
});